const express = require('express')
const bodyParser = require('body-parser')
const app = express()

const user={
    name:'范玉峰',
    psw:'123456'
}


app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())


app.post('/login',(req,res)=>{
    const {name,psw}=req.body
    if(name===user.name){
        if(psw===user.psw){
            res.send({
                code:200,
                msg:'登录成功'
            })
        }else{
            res.send({
                code:406,
                msg:'密码错误'
            })
        }

    }else{
        res.send({
            code:403,
            msg:'用户名不存在'
        })
    }

})

app.listen(3000,()=>{
    console.log('start at port 3000')
})